pp108 : Rule Elements

Rule Elements

This topic describes the different elements of a rule.

The following elements are used to define rule behavior.

Condition


A condition element is an expression that evaluates whether a condition is true or false. It is the 'if' part of a rule. The condition consists of an expression defined on the elements of an object's template. A condition can consist of multiple conditions connected by logical operators (AND, OR, etc.), which should all be part of a single expression. You can either drag the required attributes or operators from the function library and the object templates onto the condition section to build the condition expression, or type the complete expression, or do a combination of both.

Example of a Condition


Based on the example in the precondition section, suppose you want to design a rule that will give a discount on the order based on the customer's rating. If the customer's rating is 'A', then a discount of 15% should be given. Accordingly, a condition can be formulated, which makes the necessary check. The condition would be as follows:

Cust:Customer/Cust:Rating = "A" 

Action


The action element is the 'then' part of a rule, which specifies what needs to be done when the condition is evaluated as true or false. Rule engine offers you a host of action types that you can use to build simple as well as complex rules. It allows you to use nested actions in a rule.

Example of an Action


If the customer's rating is 'A', then a discount of 15% should be given. If the customer's rating is other than 'A', a discount of 2% should be given. Accordingly, a condition can be formulated, which makes the necessary check. Based on the condition, the action (the 'then' and the 'else' part of the rule) would be expressed as follows:

Cust:Customer/Cust:Rating = "A" then Business Object Attribute - Ord:Order/Ord:Discount  Value - 15 
else Business Object Attribute - Ord:Order/Ord:Discount  Value - 2